#include "common.h"

//get file size
int com_cac_file_size(FILE*fp)
{
	if(NULL!=fp)
	{
		fseek(fp, 0L, SEEK_SET);  //from begin
		int PosBegin = ftell(fp);     //get current pos
		fseek(fp, 0L, SEEK_END);  //to end
		int PosEnd = ftell(fp);       //get current pos
		int len= PosEnd - PosBegin;   //cac file size
		fseek(fp, 0L, SEEK_SET);  //set file pointer back
		return len;
	}
	else
	{
		printf("com_cac_file_size: file pointer is NULL\n");
		return 0;
	}
}
